﻿using System;
using System.Runtime.Serialization;
using System.Linq;
using EshubaAnalyser;

namespace Common
{
    [Serializable]
    public class EshubaBook : EshubaLink
    {
        public EshubaBook() { }

        public EshubaBook(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
            this.Name = info.TryGetValue<string>("Name");
            this.Summary = info.TryGetValue<string>("Summary");
        }

        public override void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            base.GetObjectData(info, context);
            info.AddValue("Name", Name);
            info.AddValue("Summary", Summary);
        }

        public override string GetRelativePath()
        {
            EshubaMenu parentMenu = EshubaCache.Instance.MenuCache.TryGetValue(this.ParentGuid);
            return GetParentRelativePath(parentMenu) + "\\" + this.Name;
        }

        public string DownloadUrl { get; set; }
        public string Name { get; set; }
        public string Summary { get; set; }
    }
}